//
//  ChatComplaintCell.m
//  PigMarket
//
//  Created by mac on 2019/6/21.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "ChatComplaintCell.h"
#import "MyTextView.h"

@interface ChatComplaintCell ()
/**
 title
 */
@property (nonatomic , strong) UILabel *titleLab;
/**
 选中标识
 */
@property (nonatomic , strong) UIImageView *selectImg;
@end

@implementation ChatComplaintCell

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *identifierID = @"identifier1ID";
    ChatComplaintCell *cell = [tableView dequeueReusableCellWithIdentifier:identifierID];
    if (cell == nil) {
        cell = [[ChatComplaintCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifierID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}
#pragma mark - init method
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.selectImg];
}

- (void)initLayout {
    // 布局子控件
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(18);
        make.height.mas_equalTo(20);
        make.bottom.mas_equalTo(-18);
    }];
    [self.selectImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(16, 16));
    }];
}
- (void)configComplaintTypeCellWithModel:(ChatComplaint *)model {
    self.titleLab.text = model.text;
    if (model.isSelect) {
        self.selectImg.image = [UIImage imageNamed:@"adopt_buy_selected"];

    } else {
        self.selectImg.image = [UIImage imageNamed:@"meat_cart_unchecked"];
    }
}
#pragma mark - getter and setter
- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.textColor = [UIColor colorWithHexString:@"#262626"];
        _titleLab.font = [UIFont systemFontOfSize:16];
    }
    return _titleLab;
}
- (UIImageView *)selectImg {
    if (!_selectImg) {
        _selectImg = [[UIImageView alloc] init];
    }
    return _selectImg;
}
@end
#pragma mark ---------------------------输入反馈内容 ，图片cell-----------------------
@interface ChatComplaintPhotoCell ()
/**
 title
 */
@property (nonatomic , strong)  MyTextView *myTextView;
/**
 添加图片bg
 */
@property (nonatomic , strong) UIView  *addPhotoBgView;
@end

@implementation ChatComplaintPhotoCell
+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *identifierID = @"identifier2ID";
    ChatComplaintPhotoCell *cell = [tableView dequeueReusableCellWithIdentifier:identifierID];
    if (cell == nil) {
        cell = [[ChatComplaintPhotoCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifierID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}
#pragma mark - init method
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self.contentView addSubview:self.addPhotoBgView];
    [self.contentView addSubview:self.myTextView];
}

- (void)initLayout {
    // 布局子控件
    [self.addPhotoBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.addPhotoBgView.mas_centerY);
        make.right.mas_equalTo(-15);
        make.size.mas_equalTo(CGSizeMake(80, 80));
    }];
    [self.myTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(15);
        make.right.mas_equalTo(self.addPhotoBgView.mas_left).offset(-10);
        make.height.mas_equalTo(18);
    }];
}

#pragma mark - getter and setter
- (MyTextView *)myTextView {
    if (!_myTextView) {
        _myTextView = [[MyTextView alloc] init];
        _myTextView.placeholder = @"请输入补充文字或上传截图证明…";
    }
    return _myTextView;
}
- (UIView *)addPhotoBgView {
    if (!_addPhotoBgView) {
        _addPhotoBgView = [[UIView alloc] init];
        _addPhotoBgView.backgroundColor = [UIColor colorWithHexString:@"#E3E3E3"];
    }
    return _addPhotoBgView;
}
@end
